package cn.ekuma.epos.bean.util;

import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.Icon;
import javax.swing.ImageIcon;

import com.openbravo.data.loader.ImageUtils;
import com.openbravo.pos.bean.FloorExt;
import com.openbravo.pos.util.ThumbNailBuilder;

public class FloorExtHelper {
	private static Image defimg ; 
	
	public static Image getDefimg(Class c){
		if(defimg==null)
			try {
				defimg = ImageIO.read(c.getClassLoader().getResourceAsStream("com/openbravo/images/atlantikdesigner.png"));
			} catch (IOException e) {
				e.printStackTrace();
			}
		return defimg;
	}
	
	 public static Icon getIcon(FloorExt ext){
	        ThumbNailBuilder tnbcat = new ThumbNailBuilder(32, 32, defimg);
	        return new ImageIcon(tnbcat.getThumbNail(ImageUtils.readImage(ext.getImage())));
	  }
}
